#!/bin/python3

import argparse
from mugen_riscv import TestEnv
import os
import paramiko
import sys
from utils import config, deps, log


def main():
    if sys.platform not in ['linux']:
        log.error(f'Unsupported platform {sys.platform}')
        exit(-1)

    parser = argparse.ArgumentParser()
    parser.add_argument('command', type=str, choices=['test', 'setup'], help='command')
    parser.add_argument('-c', '--config', type=str, required=True, help='yaml config file, create default '
                                                                        'configuration if not exists')
    args = parser.parse_args()

    if not deps.check():
        log.error('Check dependent commands failed')
        exit(-1)

    config.load(args.config)
    if not config.is_loaded():
        log.error('Load configuration failed')
        exit(-1)

    test_env = TestEnv()
    test_env.clear_env()
    test_env.print_suite_num()

    if os.getuid() != 0 and os.getgid() != 0:
        log.error("This util should run as root")
        exit(-1)


if __name__ == "__main__":
    main()
